package com.example.zbh.lessona;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.example.zbh.lessona.adapter.MainPagerAdapter;
import com.example.zbh.lessona.baidu.BaiDuActivity;
import com.example.zbh.lessona.camera.CameraActivity;
import com.example.zbh.lessona.entity.ActivityInfo;
import com.example.zbh.lessona.eventbus.BusActivity;
import com.example.zbh.lessona.face.FaceActivity;
import com.example.zbh.lessona.file.FileActivity;
import com.example.zbh.lessona.getcolor.GetColorActivity;
import com.example.zbh.lessona.media.MediaActivity;
import com.example.zbh.lessona.reference.ReferenceActivity;
import com.example.zbh.lessona.scan.ScanActivity;
import com.example.zbh.lessona.sensor.SensorActivity;
import com.example.zbh.lessona.thread.ThreadActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by nanchaodong on 15/12/31.
 */
public class MainActivity extends Activity implements AdapterView.OnItemClickListener {
    private ListView listView;
    private List<ActivityInfo> list;
    private MainPagerAdapter mainPagerAdapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_import);
        init();
    }

    private void init() {
        listView = (ListView) findViewById(R.id.listView);
        list = new ArrayList<>();
        list.add(new ActivityInfo("百度地图", BaiDuActivity.class));
        list.add(new ActivityInfo("相机", CameraActivity.class));
        list.add(new ActivityInfo("使用eventbus", BusActivity.class));
        list.add(new ActivityInfo("发表情", FaceActivity.class));
        list.add(new ActivityInfo("建文件", FileActivity.class));
        list.add(new ActivityInfo("获取bitmap颜色", GetColorActivity.class));
        list.add(new ActivityInfo("音乐播放", MediaActivity.class));
        list.add(new ActivityInfo("引用", ReferenceActivity.class));
        list.add(new ActivityInfo("扫描二维码", ScanActivity.class));
        list.add(new ActivityInfo("传感器", SensorActivity.class));
        list.add(new ActivityInfo("进程间通信", ThreadActivity.class));
        mainPagerAdapter = new MainPagerAdapter();
        listView.setAdapter(mainPagerAdapter);
        mainPagerAdapter.addData(list);
        listView.setOnItemClickListener(this);


    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        Intent intent = new Intent();
        intent.setClass(this, list.get(position).name);
        startActivity(intent);
    }
}
